package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.ItemSortMapper;
import com.jt.pojo.ItemSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemSortServiceImpl implements ItemSortService{

    @Autowired
    private ItemSortMapper itemSortMapper;

    /**
     * 显示分类的商品页面
     * 根据前端传过来的数据  一级或二级的 id
     * 点击一级分类:
     *      where group_id in 所有该一级id 的子分类id
     * 点击二级分类:
     *      where group_id = 二级的id
     *
     *
     * @param id
     * @return
     */
    @Override
    public List<ItemSort> findItemSortList(Integer id) {
        QueryWrapper<ItemSort> queryWrapper = new QueryWrapper();
        queryWrapper.eq("group_id",id);
        //SELECT * FROM ITEMSORT where group_id = 9

        return itemSortMapper.selectList(queryWrapper);
    }
}
